package com.demo.java.spring.ioc;

import org.springframework.beans.factory.support.GenericBeanDefinition;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class SpringDebugTest {
    public static void main(String[] args) {
//        ClassPathXmlApplicationContext applicationContext = new ClassPathXmlApplicationContext("classpath:applicationContext-children.xml");
//        Children children = applicationContext.getBean(Children.class);

//        MyClassPathXmlApplicationContext applicationContext = new MyClassPathXmlApplicationContext("classpath:applicationContext-other.xml");
        ClassPathXmlApplicationContext applicationContext = new ClassPathXmlApplicationContext("classpath:applicationContext.xml");
        Cat cat = applicationContext.getBean(Cat.class);
        cat.hello("world");

//        final Cat bean = ApplicationContextHolder.getBean(Cat.class);

/*
        System.out.println("================== tart custom bean definition and register bean definition");
        GenericBeanDefinition beanDefinition = new GenericBeanDefinition();
        beanDefinition.setBeanClass(Children.class);
        beanDefinition.setInstanceSupplier(SpringDebugTest::createChildren);

        BeanFactoryAwareTest.registerBeanDefinition(Children.class.getSimpleName(), beanDefinition);
        applicationContext.refresh();*/
    }

    public static Children createChildren() {
        return new Children();
    }
}
